package com.android.baselibrary.view

import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.View
import com.android.baselibrary.utils.dp2px


/**
 * view添加边框
 */
fun View.borderStyle(radius: Int = 0, borderColor: Int = Color.BLACK, borderWidth: Int = 1,strokeColor:Int = Color.TRANSPARENT) {
    val gradientDrawable1 = GradientDrawable()
    gradientDrawable1.setStroke(dp2px(context, borderWidth), borderColor)
    gradientDrawable1.setColor(strokeColor)
    gradientDrawable1.shape = GradientDrawable.RECTANGLE
    gradientDrawable1.cornerRadius = dp2px(context, radius).toFloat()
    background = gradientDrawable1
}
